﻿using System;
using Microsoft.SharePoint;
using WoltersKluwer.SPChainGang.Core.ExtensionMethods;

namespace WoltersKluwer.SPChainGang.Core.Data.Entity
{
    public class ConfigurationMapping : BaseEntity, IComparable<ConfigurationMapping>
    {

        public ConfigurationMapping(SPListItem item) : base(item)
        {
        }

        public string OldUrlPattern
        {
            get
            {
                return Item.GetString(Constants.Fields.ConfigurationListFields.Target.InternalName);
            }
        }

        public string NewUrlPattern
        {
            get
            {
                return Item.GetString(Constants.Fields.ConfigurationListFields.Destination.InternalName);
            }
        }

        public int? NestingLevel
        {
            get
            {
                return Item.GetNullableInt(Constants.Fields.ConfigurationListFields.Level.InternalName);
            }
        }

        public int CompareTo(ConfigurationMapping other)
        {
            return OldUrlPattern.Length - other.OldUrlPattern.Length;
        }
    }
}
